﻿using System;
using Ewk.Math.ComputationTypes.Computables;

namespace Ewk.Math.ComputationTypes.Factories
{
    class ComputableFunctionFactory<T, TResult> : IComputableFactory<Function<T, TResult>>
        where T : struct, IComparable, IFormattable, IConvertible, IComparable<T>, IEquatable<T>
        where TResult : struct, IComparable, IFormattable, IConvertible, IComparable<TResult>, IEquatable<TResult>
    {
        #region Implementation of IComputableFactory<Function<T,TResult>>
        public Computable<Function<T, TResult>> Zero
        {
            get
            {
                return new ComputableFunction<T, TResult>
                    (
                        new Function<T, TResult>
                            (
                                x => Computable<TResult>.Factory.Zero
                            )
                    );
            }
        }

        public Computable<Function<T, TResult>> Epsilon
        {
            get
            {
                return new ComputableFunction<T, TResult>
                    (
                        new Function<T, TResult>
                            (
                                x => Computable<TResult>.Factory.Epsilon
                            )
                    );
            }
        }

        public Computable<Function<T, TResult>> One
        {
            get
            {
                return new ComputableFunction<T, TResult>
                    (
                        new Function<T, TResult>
                            (
                                x => Computable<TResult>.Factory.One
                            )
                    );
            }
        }

        public Computable<Function<T, TResult>> MinValue
        {
            get
            {
                return new ComputableFunction<T, TResult>
                    (
                        new Function<T, TResult>
                            (
                                x => Computable<TResult>.Factory.MinValue
                            )
                    );
            }
        }

        public Computable<Function<T, TResult>> MaxValue
        {
            get
            {
                return new ComputableFunction<T, TResult>
                    (
                        new Function<T, TResult>
                            (
                                x => Computable<TResult>.Factory.MaxValue
                            )
                    );
            }
        }

        public Computable<Function<T, TResult>> Create(Function<T, TResult> value)
        {
            return new ComputableFunction<T, TResult>(value);
        }
        #endregion
    }
}